package com.czxy.Test;


import com.czxy.domain.User;
import com.czxy.service.UserService;
import com.github.pagehelper.PageInfo;

import java.util.Date;
import java.util.List;

public class demo02 {
    public static void main(String[] args) {

//        m01();
//        m02();
//        m03();
//        m04();
//        m05();
//        m06();
//        m07();
//          m08();
        m09();


    }
    public  static void  m09(){
        UserService userService = new UserService();

        User u = new User();
        u.setAddress("北京");
        u.setSex("女");
        userService.updateByInfo(u);

    }






    public  static void  m08(){
        UserService userService = new UserService();

        User u = new User();
        u.setAddress("上海");
        userService.delByInfo(u);

    }



    public  static void  m07(){
        UserService userService = new UserService();

        User u = new User();
        u.setUsername("四");
        u.setSex("nan");
        List<User> user = userService.findUserByInfo(u);
        for (User us : user) {
            System.out.println(us);
        }



    }

    public  static void  m06(){
        UserService userService = new UserService();

        User u = new User();
        u.setUid(12);
        u.setUsername("李四");
        u.setSex("nan");
        userService.updateSelective(u);



    }













    //根据主键删除

    public  static void  m05(){
        UserService userService = new UserService();

        userService.del(11);



    }



    //添加


    public  static void  m04(){

        UserService userService = new UserService();

        User user = new User(2, "@@@", new Date(), "女", "");

        userService.add(user);


    }




    //分页查询

    public  static  void m03(){

        UserService userService = new UserService();

        PageInfo pageInfo = userService.findFy(1, 2);
        List<User> list = pageInfo.getList();

        for (User user : list) {

            System.out.println(user);
        }

    }




    //根据主键查询

    public  static void  m02(){
        UserService userService = new UserService();

        User user  = new User();

        user.setUid(2);

        User u = userService.findUid(user);

        System.out.println(u);


    }



    //查询所有

    public  static void  m01() {

        UserService userService = new UserService();


        List<User> list = userService.findAll();

        for (User user : list) {

            System.out.println(user);
        }


    }


}
